﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;

namespace QMSDAL
{
    public class Department
    {
        //获取连接字符串
        public static string cnstr = ConfigurationManager.ConnectionStrings["HRAPP"].ConnectionString.ToString();

        /// <summary>
        /// 获取工程编号、机型、机号
        /// </summary>
        /// <returns></returns>
        public static DataSet GetAllDept()
        {
            using (SqlConnection cn = new SqlConnection(cnstr))
            {
                DataSet ds = new DataSet();
                cn.Open();
                string strSQL = "SELECT Bmdm FROM TYBMB";
                SqlDataAdapter cmd = new SqlDataAdapter(strSQL, cn);
                cmd.Fill(ds);

                return ds;
            }
        }

        public static DataSet GetADept(string department)
        {
            using (SqlConnection cn = new SqlConnection(cnstr))
            {
                DataSet ds = new DataSet();
                cn.Open();
                string strSQL = "SELECT Bmdm FROM TYBMB WHERE Bmdm = '"
                    + department + "'";
                SqlDataAdapter cmd = new SqlDataAdapter(strSQL, cn);
                cmd.Fill(ds);
                return ds;
            }
        }
    }
}
